﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pong_Project.Views;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Pong_Project
{
    class ViewManager
    {
        private Menu menu;
        private Help help;
        private Settings settings;
        private About about;
        private InGame inGame;
        private Pause pause;
        private Winner winner;
        private ChoosePowerupsSettings choosePowerupSetting;
        private ChooseColorSettings chooseColorSettings;
        private static GameState currentState;

        public ViewManager()
        {
            menu = new Menu();
            help = new Help();
            settings = new Settings();
            about = new About();
            inGame = new InGame();
            pause = new Pause();
            winner = new Winner();
            choosePowerupSetting = new ChoosePowerupsSettings();
            chooseColorSettings = new ChooseColorSettings();
        }

        public void LoadContent(ContentManager contentManager)
        {
            menu.LoadContent(contentManager);
            help.LoadContent(contentManager);
            settings.LoadContent(contentManager);
            about.LoadContent(contentManager);
            inGame.LoadContent(contentManager);
            pause.LoadContent(contentManager);
            winner.LoadContent(contentManager);
            choosePowerupSetting.LoadContent(contentManager);
            chooseColorSettings.LoadContent(contentManager);
        }

        public static GameState State
        {
            get { return currentState; }
            set { currentState = value; }
        }

        public void Update(GameTime gameTime)
        {
            Controls.Update();
            switch (currentState)
            {
                case GameState.Menu:
                    menu.Update(gameTime);
                    break;
                case GameState.Help:
                    help.Update(gameTime);
                    break;
                case GameState.Settings:
                    settings.Update(gameTime);
                    break;
                case GameState.About:
                    about.Update(gameTime);
                    break;
                case GameState.InGame:
                    inGame.Update(gameTime);
                    break;
                case GameState.Pause:
                    pause.Update(gameTime);
                    break;
                case GameState.Winner:
                    winner.Update(gameTime);
                    break;
                case GameState.ChoosePowerups:
                    choosePowerupSetting.Update(gameTime);
                    break;
                case GameState.ChooseColors:
                    chooseColorSettings.Update(gameTime);
                    break;
                default:
                    break;
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            switch (currentState)
            {
                case GameState.Menu:
                    menu.Draw(spriteBatch);
                    break;
                case GameState.Help:
                    help.Draw(spriteBatch);
                    break;
                case GameState.Settings:
                    settings.Draw(spriteBatch);
                    break;
                case GameState.About:
                    about.Draw(spriteBatch);
                    break;
                case GameState.InGame:
                    inGame.Draw(spriteBatch);
                    break;
                case GameState.Pause:
                    pause.Draw(spriteBatch);
                    break;
                case GameState.Winner:
                    winner.Draw(spriteBatch);
                    break;
                case GameState.ChoosePowerups:
                    choosePowerupSetting.Draw(spriteBatch);
                    break;
                case GameState.ChooseColors:
                    chooseColorSettings.Draw(spriteBatch);
                    break;
                default:
                    break;
            }
        }
    }
}
